#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
long long a[200010];
bool check[200010];
long long res;

void dfs(int now)
{
    if (now > n)
    {
        long long cnt = 0;
        for (int i = 1 ; i <= n ; i++)
        {
            for (int j = i-1 ; j >= 1 ; j--)
            {
                if (check[i] == check[j] && a[i] == a[j])
                    cnt += a[i];
            }
        }
        res = max(res, cnt);
        return;
    }
    check[now] = true;
    dfs(now+1);
    check[now] = false;
    dfs(now+1);
    return;
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;
    for (int t = 1 ; t <= T ; t++)
    {
        memset(check, 0, sizeof(check));
        cin >> n;
        for (int i = n ; i >= 1 ; i--)
            cin >> a[i];
        dfs(1);
        cout << res << endl;
        res = 0;
    }
    return 0;
}